package com.beaven.model.data.helper;

import com.beaven.model.model.api.RspModel;
import com.beaven.model.model.api.account.AccountRspModel;
import com.beaven.model.model.api.account.LoginModel;
import com.beaven.model.model.api.account.RegisterModel;
import com.beaven.model.model.api.account.UpdatePwdModel;
import com.beaven.model.model.api.user.UserUpdateModel;
import com.beaven.model.model.card.UserCard;
import com.beaven.model.net.HTTPService;
import com.beaven.model.net.NetFactory;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * author: Beaven
 * time: 2017/5/24 14:44
 */

public class AccountHelper {

  public static Observable<RspModel<AccountRspModel>> register(RegisterModel registerModel) {
    HTTPService service = NetFactory.getService();
    return service.register(registerModel)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread());
  }

  public static Observable<RspModel<AccountRspModel>> login(LoginModel loginModel) {
    HTTPService service = NetFactory.getService();
    return service.login(loginModel)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread());
  }

  public static Observable<RspModel<AccountRspModel>> logout() {
    HTTPService service = NetFactory.getService();
    return service.logout().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
  }

  public static Observable<RspModel<UserCard>> updateUser(UserUpdateModel updateModel) {
    HTTPService service = NetFactory.getService();
    return service.updateUser(updateModel)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread());
  }

  public static Observable<RspModel<UserCard>> updatePwd(UpdatePwdModel model) {
    HTTPService service = NetFactory.getService();
    return service.updatePwd(model)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread());
  }
}
